<?php

class Solution
{

    /**
     * @param Integer $numRows
     * @return Integer[][]
     */
    function generate($numRows)
    {
        if ($numRows === 0) {
            return [];
        }
        if ($numRows < 0 || $numRows === 1) {
            return [[1]];
        }

        if ($numRows === 2) {
            return [[1], [1, 1]];
        }

        $arr = $this->generate($numRows - 1);
        //正整数
        $tmp = [];
        $tmp[0] = 1;
        $lastLine = $arr[$numRows - 2];
        for ($i = 1; $i < $numRows - 1; $i++) {
            $tmp[$i] = $lastLine[$i - 1] + $lastLine[$i];
        }
        $tmp[$numRows - 1] = 1;
        $arr[] = $tmp;
        return $arr;
    }
}
